<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button onclick="getMessage()">渲染数据</button>
<input type="text" id="search-input">

<script>
    function getMessage() {
        //创建一个新的XMLHttpRequest用来帮助我们实现ajax
        var request = new XMLHttpRequest();
        //设置XMLHttpRequest的回调函数
        //request.readyState 1 2 3 4 了解第四个值
        //request.status响应状态码
        request.onreadystatechange = function () {
            if (request.readyState === 4 && request.status === 200) {
                //接受结果，打印结果
                console.log(request.responseText)
                //渲染到页面当中
                //var elementById = document.getElementById("search-input");
                //elementById.value = request.responseText;
                //去我们想要去的网页
                window.location.href = "https://www.xiaomi.com";
                alert("渲染了")
            }
        }
        //设置请求的资源路径，并且能够进行请求发送
        request.open("GET", "/conversation_test_war/hello?username=zhangsan")
        request.send();
    }
</script>
</body>
</html>